<?php


namespace app\common\model\tang;

use app\common\impl\Comm;
use app\common\model\CommonBaseModel;
use app\common\model\tang\Merchant;
use think\Facade\Db;

class MerchantEmployees extends CommonBaseModel implements Comm
{

    public function getAdminPageData($param = [], $order = 'id desc',$where=[])
    {
        if (isset($param["merchant_id"]) && !empty($param['merchant_id'])) {
            $where[] = ["merchant_id", "=", $param['merchant_id']];
        }
        if (isset($param["name"]) && !empty($param['name'])) {
            $where[] = ["name", "like", "%{$param['name']}%"];
        }
        if (isset($param["status"]) && !empty($param['status'])) {
            $where[] = ["status", "=", $param['status']];
        }
        $model = self::where($where);
        $data = $model->with(['merchant'])->order($order)->where($where)->page(PAGE)->limit(LIMIT)->select()->toArray();
        $count = count($data);
        return parent::ajaxResult($data,$count);

    }

    public function delById($id)
    {
        // TODO: Implement delById() method.
    }

    public function doAll($data)
    {
        // TODO: Implement doAll() method.
        return parent::doAllData($data);
    }
    public function merchant(){
        return $this->hasOne(Merchant::class,'id','merchant_id')->field('id,merchant_sn,name,company,code,berth_number');;
    }
}